<?php

namespace App\Services\IdentityOcr\Drivers;

use App\Services\IdentityOcr\IdentityOcrResult;
use App\Services\IdentityOcr\IdentityOcrVerifier;
use Illuminate\Support\Facades\Log;

class LogIdentityOcrVerifier implements IdentityOcrVerifier
{
    protected array $config;

    public function __construct(array $config = [])
    {
        $this->config = $config;
    }

    public function recognize(string $imagePath): IdentityOcrResult
    {
        $mock = [
            'name' => '张三',
            'idNumber' => '110101199001011234',
            'gender' => '男',
            'address' => '北京市朝阳区虚拟大道 100 号',
            'nation' => '汉',
            'birthday' => '1990-01-01',
        ];

        Log::info('[IdentityOCR][Log] mock recognize', [
            'path' => $imagePath,
            'mock' => $mock,
        ]);

        return IdentityOcrResult::success($mock);
    }

    public function recognizeWithIdentity(
        string $fullName,
        string $identityCard,
        string $frontImagePath,
        string $backImagePath
    ): IdentityOcrResult {
        $mock = [
            'name' => $fullName,
            'idNumber' => $identityCard,
            'gender' => '男',
            'address' => '北京市朝阳区模拟地址100号',
            'nation' => '汉',
            'birthday' => '1990-01-01',
            'frontPath' => $frontImagePath,
            'backPath' => $backImagePath,
        ];

        Log::info('[IdentityOCR][Log] mock recognizeWithIdentity', [
            'fullName' => $fullName,
            'identityCard' => $identityCard,
            'front' => $frontImagePath,
            'back' => $backImagePath,
            'mock' => $mock,
        ]);

        return IdentityOcrResult::success($mock, '模拟身份证识别成功');
    }
}
